/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bancodedados3d;

/**
 *
 * @author fosa
 */
import conexaobancodedados.*;
import javax.swing.JTree;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static Conect1 GlConexão = new Conect1();
    public static Consulta GlConsulta = new Consulta();
    public static Login GlLogin;
    public static janela GlJanela;

    @SuppressWarnings("static-access")
    public static void main(String[] args) {
        // TODO code application logic here
        init();

        GlJanela.show();
        GlLogin.show();

    }

    public static void setjtreejanela() {
        Main.GlJanela.setJtree();
        System.out.println("fosa");
    }

    public void setJtree() {
        JTree jTree1 = new javax.swing.JTree();
        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Bancos de Dados");
        javax.swing.tree.DefaultMutableTreeNode treeNode2 = null;

        Object[][][] bancos = Main.GlConsulta.consulta("show databases");
//        int i;
        for (int i = 0; i < bancos[1].length; i++) {
            treeNode2 = new javax.swing.tree.DefaultMutableTreeNode(bancos[1][i][0].toString());
            System.out.println(bancos[1][i][0]);
            treeNode1.add(treeNode2);
        }

//        TreeNode[] treeNode2 = new javax.swing.tree.DefaultMutableTreeNode[]{};
//        treeNode1.add(treeNode2[1]);

        jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
//        return i;
    }

    private static void init() {
        GlConexão = new Conect1();
        GlConsulta = new Consulta();
        GlJanela = new janela();
        GlLogin = new Login();

        GlJanela.show();
        GlLogin.show();
    }
}
